<?php 
	session_start(); 
	include('./langues/francais.php');
	
	try
	{
		$bdd = new PDO('mysql:host=localhost;dbname=unmei', 'root', '');
	}
	catch(Exception $e)
	{
		die('Erreur : '.$e->getMessage());
	}
	$req = $bdd->query('SELECT * FROM admin_config');
	$config = $req->fetch();
	$nombre_articles_page=$config['nombre_articles'];
	$bleu = $config['couleur_bleu'];
	$sable = $config['couleur_sable'];
	$blanc = $config['couleur_blanc'];
	$neutre = $config['couleur_neutre'];
	$fonce = $config['couleur_fonce'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">

<head>
	<title><?php echo $config['nom'] . ', ' . $config['slogan']; ?></title>
	
	<meta name="Description" content="Phrases pertinentes" />
	<meta name="Keywords" content="Mots pertinent" />

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!--<link rel="stylesheet" media="screen" type="text/css" href="./styles/style.css" />-->
	<link href="./styles/style.php" rel="stylesheet" type="text/css" media="all" />
	
	<meta name="language" content="french, FR, francais" />
	<meta http-equiv="content-language" content="fr" />
	<meta name="generator" content="Notepad++" />
	<meta name="identifier-url" content="http://www.hivana.net" />
	<meta name="publisher" content="Hivana" />
	<meta name="author" content="Hivana" />
	<meta name="owner" content="Hivana" />
	<meta name="rights" content="Tous droits r&eacute;serv&eacute;s &#169; Hivana" />
	<meta name="rating" content="general, g" />
	<meta name="audience" content="all" />
	<meta name="distribution" content="global" />
	
	<!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
		
	<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
	<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "table,inlinepopups",
			// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,table,removeformat,code",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "top",
		theme_advanced_resizing : true,
			// Example content CSS (should be your site CSS)
		content_css : "./style_editeur.css",
			// Style formats
		style_formats : [
			{title : 'Bold text', inline : 'b'},
			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
			{title : 'Example 1', inline : 'span', classes : 'example1'},
			{title : 'Example 2', inline : 'span', classes : 'example2'},
			{title : 'Table styles'},
			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
		],
		formats : {
			alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
			aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
			alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
			alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
			bold : {inline : 'span', 'classes' : 'bold'},
			italic : {inline : 'span', 'classes' : 'italic'},
			underline : {inline : 'span', 'classes' : 'underline', exact : true},
			strikethrough : {inline : 'del'},
			customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
		}
	});
	</script>
</head>

<!--[if IE 6 ]><body class="ie6 old_ie"><![endif]-->
<!--[if IE 7 ]><body class="ie7 old_ie"><![endif]-->
<!--[if IE 8 ]><body class="ie8"><![endif]-->
<!--[if IE 9 ]><body class="ie9"><![endif]-->
<!--[if !IE]><!--><body><!--<![endif]-->
	
<div id="content">
	<?php
		
		if (isset($_GET['page'])) 
		{
			$page=$_GET['page'];

			switch ($page)
			{
				case 'connexion':
					$req = $bdd->prepare('SELECT id,groupe_id FROM membres WHERE identifiant = :identifiant AND motdepasse = :motdepasse');
					$req->execute(array(
						'identifiant' => $_POST['identifiant'],
						'motdepasse' => $_POST['motdepasse']));
						$resultat = $req->fetch();
					if (!$resultat)
					{
						echo 'Mauvais identifiant ou mot de passe !';
					}
					else
					{
						$_SESSION['membre_id'] = $resultat['id'];
						$_SESSION['groupe'] = $resultat['groupe_id'];
						$_SESSION['identifiant'] = $_POST['identifiant'];;
					}
				break;
				case 'deconnexion':
					//echo "deconnexion";
					$_SESSION = array();
					session_destroy();
				break;
				default:
					// Page par defaut, est redirigée vers page=articles via le else
				break;
			}
		}
		else // Il manque des paramètres, on avertit le visiteur
		{
			echo 'Aucune action donc afficher par défaut';
			header('Location: page.php?page=articles');
		}
	?>

		<div id="logo">
			<h1><?php echo $config['nom']; ?></h1>
			<h2><?php echo $config['slogan']; ?></h2>
		</div>
		
		<div id="nav">
			<ul>
				<li><a href="page.php">Infos</a></li>
				<li><a href="page.php?page=chroniques">Chroniques</a></li>
				<li><a href="page.php?page=mondes">Monde</a></li>
				<li><a href="page.php?page=admin_config">Administration</a></li>
				<li><a href="page.php?page=faq">FAQ</a></li>
				<li><a href="#">Contact</a></li>
			</ul>
		</div>
		
		<div id="cont">

			<div id="side-menu">
				<div id="module-membres">
					<?php
					if (isset($_SESSION['identifiant']))
					{
						?>
						<p><?php echo BONJOUR; ?> <?php echo $_SESSION['identifiant']; ?></p>
						<ul>
							<li><a href="#">Ma fiche</a></li>
							<li><a href="page.php?page=membre_chroniques">Ma chronique</a></li>
							<li><a href="page.php?page=admin_index">Administration</a></li>
							<li><a href="page.php?page=deconnexion"><?php echo SE_DECONNECTER; ?></a></li>
						</ul>
						<?php
					}
					else
					{
						?>
						<form method="post" action="page.php?page=connexion">
							<p>
							<label for="identifiant"><?php echo IDENTIFIANT; ?></label>  : <input type="text" name="identifiant" id="identifiant" placeholder="Identifiant de connexion" size="20" maxlength="10" /><br />
							<label for="motdepasse"><?php echo MOT_DE_PASSE; ?></label>  : <input type="password" name="motdepasse" id="motdepasse" placeholder="Mot de passe de connexion" size="20" maxlength="10" /><br />
							<input type="submit" value="<?php echo SE_CONNECTER; ?>" /> <br/>
                            <input type="checkbox" name="souvenir" id="souvenir" checked /> 
                            <label for="souvenir"><?php echo RESTER_CONNECTE; ?></label>
							<p><a href="page.php?page=<?php echo INSCRIPTION; ?>">
							<?php echo INSCRIPTION; ?></a> | <a href="#"><?php echo IDENTIFIANTS_PERDUS; ?></a>
                            </p>
							</p>
						</form>
						<?php 
					}
					?>  
				</div>
				
				<div id="module-menu">
					<?php
						$prefixe=substr($page,0,5); 
						if ($prefixe=='admin')
							$menu = './admin/' . $prefixe . '_menu.php';
						else
							$menu = './modules/menu.php';
						include ($menu);
					?>
				</div>
				
				<div id="module-staff">
					<?php include ('./modules/equipe.php'); ?>
				</div>
				
				
			</div>

			<div id="corps">
			<?php
				$prefixe=substr($page,0,5); 
				if ($prefixe=='admin')
					$page = './admin/' . $page . '.php';
				else
					$page = './pages/'  .$page . '.php';
								
				switch ($page)
				{
					case $page:
						include ($page);
					break;
					case $articles:
						$numero_page=$_GET['numero_page'];
						include ('page.php?page=articles&numero_page=$numero_page');
					break;
					case $admin_articles:
						$numero_page=$_GET['numero_page'];
						include ('page.php?page=admin_articles&numero_page=$numero_page');
					break;
					default:
						include ('./pages/articles.php');
					break;
				}
				?>  
				
			</div>
			
			<?php
			if ($prefixe=='admin'){
			}
			else {
				?>
				<div id="menu-side">
				<div id="module-annonces">
					<?php
					switch ($page)
					{
						case 'admin_stats':
								echo TEXTE_STATISTIQUES; 
							break;
							
						case 'lire':
							include ('./pages/chat_salons.php');
						break;
						
						case 'inscription':
							echo TEXTE_INSCRIPTION;
						break;
						
						case 'admin_clans':
							echo TEXTE_ADMIN_CLANS;
						break;
						
						case 'admin_races':
							echo TEXTE_ADMIN_RACES;
						break;
						case 'admin_mondes':
							echo TEXTE_ADMIN_MONDES;
						break;
						case 'admin_groupes':
							echo TEXTE_ADMIN_GROUPES;
						break;
						case 'admin_membres':
							echo TEXTE_ADMIN_MEMBRES;
						break;
						default:
							echo "Résumé des évènements";
						break;
					}
					?>
				</div>
				<div id="module-partenaires">
					<h1>Partenaires</h1>
				</div>
				<div id="module-infos">
					<h1>Informations</h1>
				</div>
			</div>
		
		</div>
			
			
				
				
		
		<div id="forum">
			<div id="niveau1">
				<h1>Nom du monde niveau 1<h1>
				<p>Descriptions</p>
				<div id="niveau2">
					<h1>Nom du monde niveau 2<h1>
					<p>Descriptions</p>
					<div id="niveau3">
						<h1>Nom du monde niveau 3<h1>
						<p>Descriptions</p>
					</div>
				</div>
			</div>
			
			
		</div>
		
		
				<?php
			}
					
			?>

		<div id="footer">
		
			<div id="block-gauche">
				<h1>Statistiques</h1>
				<ul>
					<li><a href="#">Lien</a></li>
					<li><a href="#">Lien</a></li>
					<li><a href="#">Lien</a></li>
				</ul>
			</div>

			<div id="block-centre">
				<h1>Statistiques</h1>
				<p>Annonces.</p>
				<p><?php echo $config['pied']; ?></p>
			</div>

			<div id="block-droite">
				<h1>Statistiques</h1>
				<ul>
					<li><a href="#">Lien</a></li>
					<li><a href="#">Lien</a></li>
					<li><a href="#">Lien</a></li>
				</ul>
			</div>
		</div>
	</div>
</body>
</html>